function myCustomInitInstance(inst){
	eid = inst.editorId;
}

tinyMCE.init({
	mode : "specific_textareas",
	editor_selector : "tinyMCEditor",
	gecko_spellcheck : true,
	theme : "advanced",
    theme_advanced_buttons1 : "bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright, justifyfull,bullist,numlist,imgupload,undo,redo,link,unlink",
    theme_advanced_buttons2 : "",
    theme_advanced_buttons3 : "",
    theme_advanced_toolbar_location : "top",
    theme_advanced_toolbar_align : "left",
    init_instance_callback : "myCustomInitInstance",
    setup : function(ed) {
    			ed.addCommand('insertimage', function (r, a){
    				console.log(r);
    				ed.focus();
    				if (a == 'center'){
    					ed.selection.setContent("<img class='c-align' src='/img?k="+r+"'>");
    				}
    				if (a =='left'){
    					ed.selection.setContent("<img align='left' src='/img?k="+r+"'>");
    				}
    				if (a =='right'){
    					ed.selection.setContent("<img align='right' src='/img?k="+r+"'>");
    				}
    			});
    			
        		ed.addButton('imgupload', {
            		title : 'Upload Image',
            		image : '/i/upload.gif',
            		onclick : function() {
								tb_show('Upload Image','/admin/?a=uploadimage&type=upload&modal=true');
            				}
            		
        		});
    		}
});